import pandas as pd


def main():
    # 读取 CSV 文件
    df = pd.read_csv('Week_ Four/titanic.csv')
    # （1）统计乘客人数
    total_passengers = len(df)
    # （2）统计男、女乘客总人数及男乘客比例
    male_passengers = len(df[df['Sex'] == 'male'])
    female_passengers = len(df[df['Sex'] == 'female'])
    male_ratio = male_passengers / total_passengers if total_passengers > 0 else 0
    # （3）计算大于 35 岁人员姓名
    passengers_over_35 = df[df['Age'] > 35]['Name'].tolist()
    # （4）计算平均票价
    average_fare = df['Fare'].mean()
    print(f"乘客总人数: {total_passengers}")
    print(f"男乘客人数: {male_passengers}")
    print(f"女乘客人数: {female_passengers}")
    print(f"男乘客比例: {male_ratio:.2%}")
    print(f"大于 35 岁的乘客姓名: {passengers_over_35}")
    print(f"平均票价: {average_fare:.2f}")


if __name__ == "__main__":
    main()